package com.xinqi.modules.exam.common.enums;

import com.xinqi.common.redis.delayed.api.DelayQueueName;
import com.xinqi.modules.exam.common.constants.ExamConstants;

import java.util.Objects;

/**
 * 测评队列枚举
 *
 * @author linkai
 * @date 2023/7/7
 */
public enum ExamQueueEnum implements DelayQueueName {
    发布测评(ExamConstants.Queue.EXAM_RELEASE_QUEUE),
    开始测评(ExamConstants.Queue.EXAM_START_QUEUE),
    结束测评(ExamConstants.Queue.EXAM_END_QUEUE),
    延时批阅(ExamConstants.Queue.EXAM_DELAY_MARK_QUEUE),

    /**
     * 生成试卷
     */
    生成试卷(ExamConstants.Topic.GENERATE_STUDENT_PAPER_TOPIC),
    /**
     * 开始试卷
     */
    开始试卷(ExamConstants.Topic.START_EXAM_TOPIC),
    /**
     * 结束考试
     */
    结束考试(ExamConstants.Topic.END_EXAM_TOPIC),
    /**
     * 生成测评分析
     */
    生成测评分析(ExamConstants.Topic.GENERATE_EXAM_ANALYZE_TOPIC),

    ;

    private final String queueName;

    ExamQueueEnum(String queueName) {
        this.queueName = queueName;
    }

    @Override
    public String queueName() {
        return this.queueName;
    }

    public static ExamQueueEnum of(String queueName) {
        for (ExamQueueEnum value : ExamQueueEnum.values()) {
            if (Objects.equals(value.queueName, queueName)) {
                return value;
            }
        }
        return null;
    }
}
